package cn.com.xyc.inter.impl;

import java.io.File;
import java.io.FileNotFoundException;

import org.springframework.stereotype.Service;

import cn.com.xyc.common.ALiYunTool;
import cn.com.xyc.common.FileManageTool;
import cn.com.xyc.common.QrCodeUtil;
import cn.com.xyc.inter.AppTools;

@Service
public class AppToolsImpl implements AppTools {
	private static int WIDTH = 200;
	private static int HEIGHT = 200;

	public String makeZXCode(String logoAddress, String content) {
		File logoImage = FileManageTool.FileDown(logoAddress);
		File qrCode = QrCodeUtil.encodeQRCodeImage(content, "UTF-8", WIDTH,
				HEIGHT, logoImage);
		String uploadPath = "qrCode/" + System.currentTimeMillis()
				+ qrCode.getName().substring(qrCode.getName().lastIndexOf("."));
		String url = null;
		try {
			url = ALiYunTool.uploadGroupIcon(qrCode, "picdata", uploadPath);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}

		return url;
	}

}
